package com.hzc.springchan.controller;

import com.hzc.springchan.annotation.CApi;
import com.hzc.springchan.bean.request.Request;
import com.hzc.springchan.bean.response.Response;
import com.hzc.springchan.enums.CResource;
import com.hzc.springchan.service.IRouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 健康检查控制器类
 * @author chen990627
 * @date 2022/10/19
 */
@RestController
@RequestMapping("/health_check")
@Api(value = "/health_check", hidden = false, description = "健康检查类接口")
public class HealthCheckController extends BaseController {

    @Autowired
    private IRouteService routeService;

    @GetMapping("/swagger-test1")
    @CApi(skipTokenCheck = true, resource = CResource.SPECIAL)
    @ApiOperation(value = "swagger测试1", httpMethod = "GET", response = Map.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = true, paramType = "query"),
            @ApiImplicitParam(name = "age", value = "年龄", required = true, paramType = "query")
    })
    public Response test1(@RequestParam("name") String name, @RequestParam("age") Integer age) {
        return requestRoute(routeService);
    }

    @PostMapping("/swagger-test2")
    @CApi(skipTokenCheck = true, resource = CResource.SPECIAL)
    @ApiOperation(value = "swagger测试2", httpMethod = "POST", response = Map.class)
    public Response test2(@RequestBody Request request) {
        return requestRoute(routeService);
    }
}
